# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import annotations

from typing import MutableMapping, MutableSequence

from google.protobuf import field_mask_pb2  # type: ignore
from google.protobuf import timestamp_pb2  # type: ignore
import proto  # type: ignore

__protobuf__ = proto.module(
    package="google.cloud.networkservices.v1",
    manifest={
        "WasmPluginView",
        "WasmPlugin",
        "WasmPluginVersion",
        "ListWasmPluginsRequest",
        "ListWasmPluginsResponse",
        "GetWasmPluginRequest",
        "CreateWasmPluginRequest",
        "UpdateWasmPluginRequest",
        "DeleteWasmPluginRequest",
        "ListWasmPluginVersionsRequest",
        "ListWasmPluginVersionsResponse",
        "GetWasmPluginVersionRequest",
        "CreateWasmPluginVersionRequest",
        "DeleteWasmPluginVersionRequest",
    },
)


class WasmPluginView(proto.Enum):
    r"""Determines the information that should be returned by the
    server.

    Values:
        WASM_PLUGIN_VIEW_UNSPECIFIED (0):
            Unspecified value. Do not use.
        WASM_PLUGIN_VIEW_BASIC (1):
            If specified in the ``GET`` request for a ``WasmPlugin``
            resource, the server's response includes just the
            ``WasmPlugin`` resource.
        WASM_PLUGIN_VIEW_FULL (2):
            If specified in the ``GET`` request for a ``WasmPlugin``
            resource, the server's response includes the ``WasmPlugin``
            resource with all its versions.
    """
    WASM_PLUGIN_VIEW_UNSPECIFIED = 0
    WASM_PLUGIN_VIEW_BASIC = 1
    WASM_PLUGIN_VIEW_FULL = 2


class WasmPlugin(proto.Message):
    r"""``WasmPlugin`` is a resource representing a service executing a
    customer-provided Wasm module.

    Attributes:
        name (str):
            Identifier. Name of the ``WasmPlugin`` resource in the
            following format:
            ``projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}``.
        create_time (google.protobuf.timestamp_pb2.Timestamp):
            Output only. The timestamp when the resource
            was created.
        update_time (google.protobuf.timestamp_pb2.Timestamp):
            Output only. The timestamp when the resource
            was updated.
        description (str):
            Optional. A human-readable description of the
            resource.
        labels (MutableMapping[str, str]):
            Optional. Set of labels associated with the ``WasmPlugin``
            resource.

            The format must comply with `the following
            requirements </compute/docs/labeling-resources#requirements>`__.
        main_version_id (str):
            Optional. The ID of the ``WasmPluginVersion`` resource that
            is the currently serving one. The version referred to must
            be a child of this ``WasmPlugin`` resource.
        log_config (google.cloud.network_services_v1.types.WasmPlugin.LogConfig):
            Optional. Specifies the logging options for
            the activity performed by this plugin. If
            logging is enabled, plugin logs are exported to
            Cloud Logging.
            Note that the settings relate to the logs
            generated by using logging statements in your
            Wasm code.
        versions (MutableMapping[str, google.cloud.network_services_v1.types.WasmPlugin.VersionDetails]):
            Optional. All versions of this ``WasmPlugin`` resource in
            the key-value format. The key is the resource ID, and the
            value is the ``VersionDetails`` object.

            Lets you create or update a ``WasmPlugin`` resource and its
            versions in a single request. When the ``main_version_id``
            field is not empty, it must point to one of the
            ``VersionDetails`` objects in the map.

            If provided in a ``PATCH`` request, the new versions replace
            the previous set. Any version omitted from the ``versions``
            field is removed. Because the ``WasmPluginVersion`` resource
            is immutable, if a ``WasmPluginVersion`` resource with the
            same name already exists and differs, the request fails.

            Note: In a ``GET`` request, this field is populated only if
            the field ``GetWasmPluginRequest.view`` is set to
            ``WASM_PLUGIN_VIEW_FULL``.
        used_by (MutableSequence[google.cloud.network_services_v1.types.WasmPlugin.UsedBy]):
            Output only. List of all
            `extensions <https://cloud.google.com/service-extensions/docs/overview>`__
            that use this ``WasmPlugin`` resource.
    """

    class VersionDetails(proto.Message):
        r"""Details of a ``WasmPluginVersion`` resource to be inlined in the
        ``WasmPlugin`` resource.

        This message has `oneof`_ fields (mutually exclusive fields).
        For each oneof, at most one member field can be set at the same time.
        Setting any member of the oneof automatically clears all other
        members.

        .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

        Attributes:
            plugin_config_data (bytes):
                Configuration for the plugin. The configuration is provided
                to the plugin at runtime through the ``ON_CONFIGURE``
                callback. When a new ``WasmPluginVersion`` version is
                created, the digest of the contents is saved in the
                ``plugin_config_digest`` field.

                This field is a member of `oneof`_ ``plugin_config_source``.
            plugin_config_uri (str):
                URI of the plugin configuration stored in the Artifact
                Registry. The configuration is provided to the plugin at
                runtime through the ``ON_CONFIGURE`` callback. The container
                image must contain only a single file with the name
                ``plugin.config``. When a new ``WasmPluginVersion`` resource
                is created, the digest of the container image is saved in
                the ``plugin_config_digest`` field.

                This field is a member of `oneof`_ ``plugin_config_source``.
            create_time (google.protobuf.timestamp_pb2.Timestamp):
                Output only. The timestamp when the resource
                was created.
            update_time (google.protobuf.timestamp_pb2.Timestamp):
                Output only. The timestamp when the resource
                was updated.
            description (str):
                Optional. A human-readable description of the
                resource.
            labels (MutableMapping[str, str]):
                Optional. Set of labels associated with the
                ``WasmPluginVersion`` resource.
            image_uri (str):
                Optional. URI of the container image containing the Wasm
                module, stored in the Artifact Registry. The container image
                must contain only a single file with the name
                ``plugin.wasm``. When a new ``WasmPluginVersion`` resource
                is created, the URI gets resolved to an image digest and
                saved in the ``image_digest`` field.
            image_digest (str):
                Output only. The resolved digest for the image specified in
                ``image``. The digest is resolved during the creation of a
                ``WasmPluginVersion`` resource. This field holds the digest
                value regardless of whether a tag or digest was originally
                specified in the ``image`` field.
            plugin_config_digest (str):
                Output only. This field holds the digest (usually checksum)
                value for the plugin configuration. The value is calculated
                based on the contents of the ``plugin_config_data`` field or
                the container image defined by the ``plugin_config_uri``
                field.
        """

        plugin_config_data: bytes = proto.Field(
            proto.BYTES,
            number=9,
            oneof="plugin_config_source",
        )
        plugin_config_uri: str = proto.Field(
            proto.STRING,
            number=10,
            oneof="plugin_config_source",
        )
        create_time: timestamp_pb2.Timestamp = proto.Field(
            proto.MESSAGE,
            number=1,
            message=timestamp_pb2.Timestamp,
        )
        update_time: timestamp_pb2.Timestamp = proto.Field(
            proto.MESSAGE,
            number=2,
            message=timestamp_pb2.Timestamp,
        )
        description: str = proto.Field(
            proto.STRING,
            number=3,
        )
        labels: MutableMapping[str, str] = proto.MapField(
            proto.STRING,
            proto.STRING,
            number=4,
        )
        image_uri: str = proto.Field(
            proto.STRING,
            number=5,
        )
        image_digest: str = proto.Field(
            proto.STRING,
            number=6,
        )
        plugin_config_digest: str = proto.Field(
            proto.STRING,
            number=11,
        )

    class LogConfig(proto.Message):
        r"""Specifies the logging options for the activity performed by
        this plugin. If logging is enabled, plugin logs are exported to
        Cloud Logging.

        Attributes:
            enable (bool):
                Optional. Specifies whether to enable logging for activity
                by this plugin.

                Defaults to ``false``.
            sample_rate (float):
                Non-empty default. Configures the sampling rate of activity
                logs, where ``1.0`` means all logged activity is reported
                and ``0.0`` means no activity is reported. A floating point
                value between ``0.0`` and ``1.0`` indicates that a
                percentage of log messages is stored.

                The default value when logging is enabled is ``1.0``. The
                value of the field must be between ``0`` and ``1``
                (inclusive).

                This field can be specified only if logging is enabled for
                this plugin.
            min_log_level (google.cloud.network_services_v1.types.WasmPlugin.LogConfig.LogLevel):
                Non-empty default. Specificies the lowest level of the
                plugin logs that are exported to Cloud Logging. This setting
                relates to the logs generated by using logging statements in
                your Wasm code.

                This field is can be set only if logging is enabled for the
                plugin.

                If the field is not provided when logging is enabled, it is
                set to ``INFO`` by default.
        """

        class LogLevel(proto.Enum):
            r"""Possible values to specify the lowest level of logs to be
            exported to Cloud Logging.

            Values:
                LOG_LEVEL_UNSPECIFIED (0):
                    Unspecified value. Defaults to ``LogLevel.INFO``.
                TRACE (1):
                    Report logs with TRACE level and above.
                DEBUG (2):
                    Report logs with DEBUG level and above.
                INFO (3):
                    Report logs with INFO level and above.
                WARN (4):
                    Report logs with WARN level and above.
                ERROR (5):
                    Report logs with ERROR level and above.
                CRITICAL (6):
                    Report logs with CRITICAL level only.
            """
            LOG_LEVEL_UNSPECIFIED = 0
            TRACE = 1
            DEBUG = 2
            INFO = 3
            WARN = 4
            ERROR = 5
            CRITICAL = 6

        enable: bool = proto.Field(
            proto.BOOL,
            number=1,
        )
        sample_rate: float = proto.Field(
            proto.FLOAT,
            number=2,
        )
        min_log_level: "WasmPlugin.LogConfig.LogLevel" = proto.Field(
            proto.ENUM,
            number=3,
            enum="WasmPlugin.LogConfig.LogLevel",
        )

    class UsedBy(proto.Message):
        r"""Defines a resource that uses the ``WasmPlugin`` resource.

        Attributes:
            name (str):
                Output only. Full name of the resource
                https://google.aip.dev/122#full-resource-names, for example
                ``//networkservices.googleapis.com/projects/{project}/locations/{location}/lbRouteExtensions/{extension}``
        """

        name: str = proto.Field(
            proto.STRING,
            number=1,
        )

    name: str = proto.Field(
        proto.STRING,
        number=1,
    )
    create_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=2,
        message=timestamp_pb2.Timestamp,
    )
    update_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=3,
        message=timestamp_pb2.Timestamp,
    )
    description: str = proto.Field(
        proto.STRING,
        number=4,
    )
    labels: MutableMapping[str, str] = proto.MapField(
        proto.STRING,
        proto.STRING,
        number=5,
    )
    main_version_id: str = proto.Field(
        proto.STRING,
        number=6,
    )
    log_config: LogConfig = proto.Field(
        proto.MESSAGE,
        number=9,
        message=LogConfig,
    )
    versions: MutableMapping[str, VersionDetails] = proto.MapField(
        proto.STRING,
        proto.MESSAGE,
        number=10,
        message=VersionDetails,
    )
    used_by: MutableSequence[UsedBy] = proto.RepeatedField(
        proto.MESSAGE,
        number=11,
        message=UsedBy,
    )


class WasmPluginVersion(proto.Message):
    r"""A single immutable version of a ``WasmPlugin`` resource. Defines the
    Wasm module used and optionally its runtime config.

    This message has `oneof`_ fields (mutually exclusive fields).
    For each oneof, at most one member field can be set at the same time.
    Setting any member of the oneof automatically clears all other
    members.

    .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

    Attributes:
        plugin_config_data (bytes):
            Configuration for the plugin. The configuration is provided
            to the plugin at runtime through the ``ON_CONFIGURE``
            callback. When a new ``WasmPluginVersion`` resource is
            created, the digest of the contents is saved in the
            ``plugin_config_digest`` field.

            This field is a member of `oneof`_ ``plugin_config_source``.
        plugin_config_uri (str):
            URI of the plugin configuration stored in the Artifact
            Registry. The configuration is provided to the plugin at
            runtime through the ``ON_CONFIGURE`` callback. The container
            image must contain only a single file with the name
            ``plugin.config``. When a new ``WasmPluginVersion`` resource
            is created, the digest of the container image is saved in
            the ``plugin_config_digest`` field.

            This field is a member of `oneof`_ ``plugin_config_source``.
        name (str):
            Identifier. Name of the ``WasmPluginVersion`` resource in
            the following format:
            ``projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}/ versions/{wasm_plugin_version}``.
        create_time (google.protobuf.timestamp_pb2.Timestamp):
            Output only. The timestamp when the resource
            was created.
        update_time (google.protobuf.timestamp_pb2.Timestamp):
            Output only. The timestamp when the resource
            was updated.
        description (str):
            Optional. A human-readable description of the
            resource.
        labels (MutableMapping[str, str]):
            Optional. Set of labels associated with the
            ``WasmPluginVersion`` resource.
        image_uri (str):
            Optional. URI of the container image containing the plugin,
            stored in the Artifact Registry. When a new
            ``WasmPluginVersion`` resource is created, the digest of the
            container image is saved in the ``image_digest`` field. When
            downloading an image, the digest value is used instead of an
            image tag.
        image_digest (str):
            Output only. The resolved digest for the image specified in
            the ``image`` field. The digest is resolved during the
            creation of ``WasmPluginVersion`` resource. This field holds
            the digest value, regardless of whether a tag or digest was
            originally specified in the ``image`` field.
        plugin_config_digest (str):
            Output only. This field holds the digest (usually checksum)
            value for the plugin configuration. The value is calculated
            based on the contents of ``plugin_config_data`` or the
            container image defined by the ``plugin_config_uri`` field.
    """

    plugin_config_data: bytes = proto.Field(
        proto.BYTES,
        number=12,
        oneof="plugin_config_source",
    )
    plugin_config_uri: str = proto.Field(
        proto.STRING,
        number=13,
        oneof="plugin_config_source",
    )
    name: str = proto.Field(
        proto.STRING,
        number=1,
    )
    create_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=3,
        message=timestamp_pb2.Timestamp,
    )
    update_time: timestamp_pb2.Timestamp = proto.Field(
        proto.MESSAGE,
        number=4,
        message=timestamp_pb2.Timestamp,
    )
    description: str = proto.Field(
        proto.STRING,
        number=5,
    )
    labels: MutableMapping[str, str] = proto.MapField(
        proto.STRING,
        proto.STRING,
        number=6,
    )
    image_uri: str = proto.Field(
        proto.STRING,
        number=8,
    )
    image_digest: str = proto.Field(
        proto.STRING,
        number=9,
    )
    plugin_config_digest: str = proto.Field(
        proto.STRING,
        number=14,
    )


class ListWasmPluginsRequest(proto.Message):
    r"""Request used with the ``ListWasmPlugins`` method.

    Attributes:
        parent (str):
            Required. The project and location from which the
            ``WasmPlugin`` resources are listed, specified in the
            following format: ``projects/{project}/locations/global``.
        page_size (int):
            Maximum number of ``WasmPlugin`` resources to return per
            call. If not specified, at most 50 ``WasmPlugin`` resources
            are returned. The maximum value is 1000; values above 1000
            are coerced to 1000.
        page_token (str):
            The value returned by the last ``ListWasmPluginsResponse``
            call. Indicates that this is a continuation of a prior
            ``ListWasmPlugins`` call, and that the next page of data is
            to be returned.
    """

    parent: str = proto.Field(
        proto.STRING,
        number=1,
    )
    page_size: int = proto.Field(
        proto.INT32,
        number=2,
    )
    page_token: str = proto.Field(
        proto.STRING,
        number=3,
    )


class ListWasmPluginsResponse(proto.Message):
    r"""Response returned by the ``ListWasmPlugins`` method.

    Attributes:
        wasm_plugins (MutableSequence[google.cloud.network_services_v1.types.WasmPlugin]):
            List of ``WasmPlugin`` resources.
        next_page_token (str):
            If there might be more results than those appearing in this
            response, then ``next_page_token`` is included. To get the
            next set of results, call this method again using the value
            of ``next_page_token`` as ``page_token``.
        unreachable (MutableSequence[str]):
            Unreachable resources. Populated when the
            request attempts to list all resources across
            all supported locations, while some locations
            are temporarily unavailable.
    """

    @property
    def raw_page(self):
        return self

    wasm_plugins: MutableSequence["WasmPlugin"] = proto.RepeatedField(
        proto.MESSAGE,
        number=1,
        message="WasmPlugin",
    )
    next_page_token: str = proto.Field(
        proto.STRING,
        number=2,
    )
    unreachable: MutableSequence[str] = proto.RepeatedField(
        proto.STRING,
        number=3,
    )


class GetWasmPluginRequest(proto.Message):
    r"""Request used by the ``GetWasmPlugin`` method.

    Attributes:
        name (str):
            Required. A name of the ``WasmPlugin`` resource to get. Must
            be in the format
            ``projects/{project}/locations/global/wasmPlugins/{wasm_plugin}``.
        view (google.cloud.network_services_v1.types.WasmPluginView):
            Determines how much data must be returned in the response.
            See `AIP-157 <https://google.aip.dev/157>`__.
    """

    name: str = proto.Field(
        proto.STRING,
        number=1,
    )
    view: "WasmPluginView" = proto.Field(
        proto.ENUM,
        number=2,
        enum="WasmPluginView",
    )


class CreateWasmPluginRequest(proto.Message):
    r"""Request used by the ``CreateWasmPlugin`` method.

    Attributes:
        parent (str):
            Required. The parent resource of the ``WasmPlugin``
            resource. Must be in the format
            ``projects/{project}/locations/global``.
        wasm_plugin_id (str):
            Required. User-provided ID of the ``WasmPlugin`` resource to
            be created.
        wasm_plugin (google.cloud.network_services_v1.types.WasmPlugin):
            Required. ``WasmPlugin`` resource to be created.
    """

    parent: str = proto.Field(
        proto.STRING,
        number=1,
    )
    wasm_plugin_id: str = proto.Field(
        proto.STRING,
        number=2,
    )
    wasm_plugin: "WasmPlugin" = proto.Field(
        proto.MESSAGE,
        number=3,
        message="WasmPlugin",
    )


class UpdateWasmPluginRequest(proto.Message):
    r"""Request used by the ``UpdateWasmPlugin`` method.

    Attributes:
        update_mask (google.protobuf.field_mask_pb2.FieldMask):
            Optional. Used to specify the fields to be overwritten in
            the ``WasmPlugin`` resource by the update. The fields
            specified in the ``update_mask`` field are relative to the
            resource, not the full request. An omitted ``update_mask``
            field is treated as an implied ``update_mask`` field
            equivalent to all fields that are populated (that have a
            non-empty value). The ``update_mask`` field supports a
            special value ``*``, which means that each field in the
            given ``WasmPlugin`` resource (including the empty ones)
            replaces the current value.
        wasm_plugin (google.cloud.network_services_v1.types.WasmPlugin):
            Required. Updated ``WasmPlugin`` resource.
    """

    update_mask: field_mask_pb2.FieldMask = proto.Field(
        proto.MESSAGE,
        number=1,
        message=field_mask_pb2.FieldMask,
    )
    wasm_plugin: "WasmPlugin" = proto.Field(
        proto.MESSAGE,
        number=2,
        message="WasmPlugin",
    )


class DeleteWasmPluginRequest(proto.Message):
    r"""Request used by the ``DeleteWasmPlugin`` method.

    Attributes:
        name (str):
            Required. A name of the ``WasmPlugin`` resource to delete.
            Must be in the format
            ``projects/{project}/locations/global/wasmPlugins/{wasm_plugin}``.
    """

    name: str = proto.Field(
        proto.STRING,
        number=1,
    )


class ListWasmPluginVersionsRequest(proto.Message):
    r"""Request used with the ``ListWasmPluginVersions`` method.

    Attributes:
        parent (str):
            Required. The ``WasmPlugin`` resource whose
            ``WasmPluginVersion``\ s are listed, specified in the
            following format:
            ``projects/{project}/locations/global/wasmPlugins/{wasm_plugin}``.
        page_size (int):
            Maximum number of ``WasmPluginVersion`` resources to return
            per call. If not specified, at most 50 ``WasmPluginVersion``
            resources are returned. The maximum value is 1000; values
            above 1000 are coerced to 1000.
        page_token (str):
            The value returned by the last
            ``ListWasmPluginVersionsResponse`` call. Indicates that this
            is a continuation of a prior ``ListWasmPluginVersions``
            call, and that the next page of data is to be returned.
    """

    parent: str = proto.Field(
        proto.STRING,
        number=1,
    )
    page_size: int = proto.Field(
        proto.INT32,
        number=2,
    )
    page_token: str = proto.Field(
        proto.STRING,
        number=3,
    )


class ListWasmPluginVersionsResponse(proto.Message):
    r"""Response returned by the ``ListWasmPluginVersions`` method.

    Attributes:
        wasm_plugin_versions (MutableSequence[google.cloud.network_services_v1.types.WasmPluginVersion]):
            List of ``WasmPluginVersion`` resources.
        next_page_token (str):
            If there might be more results than those appearing in this
            response, then ``next_page_token`` is included. To get the
            next set of results, call this method again using the value
            of ``next_page_token`` as ``page_token``.
        unreachable (MutableSequence[str]):
            Unreachable resources. Populated when the
            request attempts to list all resources across
            all supported locations, while some locations
            are temporarily unavailable.
    """

    @property
    def raw_page(self):
        return self

    wasm_plugin_versions: MutableSequence["WasmPluginVersion"] = proto.RepeatedField(
        proto.MESSAGE,
        number=1,
        message="WasmPluginVersion",
    )
    next_page_token: str = proto.Field(
        proto.STRING,
        number=2,
    )
    unreachable: MutableSequence[str] = proto.RepeatedField(
        proto.STRING,
        number=3,
    )


class GetWasmPluginVersionRequest(proto.Message):
    r"""Request used by the ``GetWasmPluginVersion`` method.

    Attributes:
        name (str):
            Required. A name of the ``WasmPluginVersion`` resource to
            get. Must be in the format
            ``projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}``.
    """

    name: str = proto.Field(
        proto.STRING,
        number=1,
    )


class CreateWasmPluginVersionRequest(proto.Message):
    r"""Request used by the ``CreateWasmPluginVersion`` method.

    Attributes:
        parent (str):
            Required. The parent resource of the ``WasmPluginVersion``
            resource. Must be in the format
            ``projects/{project}/locations/global/wasmPlugins/{wasm_plugin}``.
        wasm_plugin_version_id (str):
            Required. User-provided ID of the ``WasmPluginVersion``
            resource to be created.
        wasm_plugin_version (google.cloud.network_services_v1.types.WasmPluginVersion):
            Required. ``WasmPluginVersion`` resource to be created.
    """

    parent: str = proto.Field(
        proto.STRING,
        number=1,
    )
    wasm_plugin_version_id: str = proto.Field(
        proto.STRING,
        number=2,
    )
    wasm_plugin_version: "WasmPluginVersion" = proto.Field(
        proto.MESSAGE,
        number=3,
        message="WasmPluginVersion",
    )


class DeleteWasmPluginVersionRequest(proto.Message):
    r"""Request used by the ``DeleteWasmPluginVersion`` method.

    Attributes:
        name (str):
            Required. A name of the ``WasmPluginVersion`` resource to
            delete. Must be in the format
            ``projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}``.
    """

    name: str = proto.Field(
        proto.STRING,
        number=1,
    )


__all__ = tuple(sorted(__protobuf__.manifest))
